package com.example.actionhandlers.actions;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Intent;

import com.example.actionhandlers.AbstractAction;
import com.example.singletones.contextObj;

public class InitApplicationAction extends AbstractAction {

	public boolean isApplicable(JSONObject jsonObj) {
		try {
			return jsonObj.has("actionName")
					&& jsonObj.getString("actionName").equalsIgnoreCase(
							"initApplication");
		} catch (JSONException e) {
			return false;
		}
	}

	public void performAction(JSONObject jsonObj) throws Exception {
		Intent LaunchIntent = contextObj
				.getInstance()
				.getmContext()
				.getPackageManager()
				.getLaunchIntentForPackage(jsonObj.getString("applicationName"));
		contextObj.getInstance().getmContext().startActivity(LaunchIntent);
	}

	public String getActionName() {
		return "initApplication";
	}
}
